package client;

import ServiceI.DataServiceI;
import ServiceI.EmptyServiceI;
import org.junit.jupiter.api.Test;
import util.ThreadPool;

import java.util.concurrent.LinkedBlockingDeque;


public class ClientTest {
    public static void main(String[] args) throws InterruptedException {
        AOPClient aopClient = new AOPClient(DataServiceI.class, "127.0.0.1", 7881);
        aopClient.addServer(DataServiceI.class, "127.0.0.1", 8080);
        aopClient.addServer(DataServiceI.class, "127.0.0.1", 7880);
        aopClient.addServer(DataServiceI.class, "127.0.0.1", 9090);

        aopClient.register(EmptyServiceI.class, "127.0.0.1", 8080);
        aopClient.addServer(EmptyServiceI.class, "127.0.0.1", 7880);
        aopClient.addServer(EmptyServiceI.class, "127.0.0.1", 7881);
        aopClient.addServer(EmptyServiceI.class, "127.0.0.1", 9090);
        for (int i = 0; i < 10; i++) {
            new Thread(() -> {
                DataServiceI dataServiceI = (DataServiceI) aopClient.send(DataServiceI.class);
                String data = dataServiceI.getData(System.currentTimeMillis());
                System.out.println(Thread.currentThread().getName() + ": data = " + data);
            }).start();
        }
        EmptyServiceI emptyServiceI = (EmptyServiceI) aopClient.send(EmptyServiceI.class);
        System.out.println(emptyServiceI.getData("asdf"));
    }

    @Test
    public void asdf() {


    }
}
